import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yinsh
 * Date: 2025-01-21
 * Time: 11:53
 */
public class MyStack {
    private int[] stackList;
    private int usedSize;
    private static final int CAPCITY = 5;

    public MyStack() {
        this.stackList = new int[CAPCITY];
        this.usedSize = 0;
    }
    private void push(int data) {
        if (isFull()) {
            stackList = Arrays.copyOf(stackList,2*CAPCITY);
        }
        stackList[usedSize] = data;
        usedSize++;
    }
    private void pop() {
        usedSize--;
    }
    private int peek() {
        return stackList[usedSize - 1];
    }
    private int size() {
        return usedSize;
    }
    private boolean empty() {
        if (usedSize == 0) {
            return true;
        }
        return false;
    }
    private boolean isFull() {
        if (usedSize == CAPCITY) {
            return true;
        }
        return false;
    }
    private void display() {
        for (int i = 0; i < usedSize; i++) {
            System.out.println(stackList[i]);
        }
    }
    public static void main(String[] args) {
        MyStack myStack = new MyStack();
        myStack.push(12);
        myStack.push(23);
        myStack.push(34);
        myStack.push(45);
        myStack.push(56);
        myStack.push(67);
        myStack.pop();
        System.out.println(myStack.peek());
        myStack.display();
    }

}
